/**
 * 
 */
package com.ap.core.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.transaction.annotation.Transactional;

import com.ap.core.cxf.jaxb.common.ActivationStatus;
import com.ap.core.dao.AbstractReadOnlyAPCoreBaseJpaDao;
import com.ap.core.dao.MerchantDistributorDetailsDao;
import com.ap.core.domain.MerchantDistributorDetails;
import com.ap.core.domain.MerchantDistributorDetailsId;

/**
 * @author Dilip.Sridhar
 *
 */
public class JpaMerchantDistributorDetailsDao  extends AbstractReadOnlyAPCoreBaseJpaDao 
												        <MerchantDistributorDetails, MerchantDistributorDetailsId> 
											   implements MerchantDistributorDetailsDao  {

	@Override
	@Transactional(readOnly=true)
	public MerchantDistributorDetails findById(MerchantDistributorDetailsId primaryKey) {
		return findById(MerchantDistributorDetails.class, primaryKey);
	}

	@Override
	public MerchantDistributorDetails findByState(MerchantDistributorDetailsId merchantDistributorDetailsId, ActivationStatus merchantActivationStatus) {
		final Criteria criteria = getSession().createCriteria(MerchantDistributorDetails.class);
        criteria.add(Restrictions.eq("id", merchantDistributorDetailsId));
        criteria.add(Restrictions.eq("merchantActivationStatus", merchantActivationStatus));        
       return (MerchantDistributorDetails)criteria.uniqueResult();
	}

}
